﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 初步增加替班换班调休表 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "SysDailyCompOffRequestBill",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    PersonId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    StaffNo = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    StartTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    EndTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    Days = table.Column<decimal>(type: "decimal(8,2)", nullable: false),
                    Reason = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Approver = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    ApprovalTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    GroupId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    OrgId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    BillCode = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    BillStatus = table.Column<int>(type: "int", nullable: true),
                    WorkflowStatus = table.Column<int>(type: "int", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysDailyCompOffRequestBill", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysDailyCompOffRequestBill_FrameworkGroups_GroupId",
                        column: x => x.GroupId,
                        principalTable: "FrameworkGroups",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysDailyCompOffRequestBill_SysOrg_OrgId",
                        column: x => x.OrgId,
                        principalTable: "SysOrg",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysDailyCompOffRequestBill_SysPerson_PersonId",
                        column: x => x.PersonId,
                        principalTable: "SysPerson",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "SysDailyShiftSwapRequestBill",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    PersonId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    StaffNo = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    StartTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    EndTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    Reason = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
                    SwapShiftId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    SwapPersonId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    SwapStaffNo = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
                    SwapName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Approver = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    ApprovalTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    GroupId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    OrgId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    BillCode = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    BillStatus = table.Column<int>(type: "int", nullable: true),
                    WorkflowStatus = table.Column<int>(type: "int", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysDailyShiftSwapRequestBill", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysDailyShiftSwapRequestBill_FrameworkGroups_GroupId",
                        column: x => x.GroupId,
                        principalTable: "FrameworkGroups",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysDailyShiftSwapRequestBill_SysOrg_OrgId",
                        column: x => x.OrgId,
                        principalTable: "SysOrg",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysDailyShiftSwapRequestBill_SysPerson_PersonId",
                        column: x => x.PersonId,
                        principalTable: "SysPerson",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_SysDailyShiftSwapRequestBill_SysPerson_SwapPersonId",
                        column: x => x.SwapPersonId,
                        principalTable: "SysPerson",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "SysDailySubstitutionRequestBill",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    PersonId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    StaffNo = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    StartTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    EndTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    Reason = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
                    SubstitutePersonId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    SubstituteStaffNo = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
                    SubstituteName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Approver = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    ApprovalTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    GroupId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    OrgId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    BillCode = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    BillStatus = table.Column<int>(type: "int", nullable: true),
                    WorkflowStatus = table.Column<int>(type: "int", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysDailySubstitutionRequestBill", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysDailySubstitutionRequestBill_FrameworkGroups_GroupId",
                        column: x => x.GroupId,
                        principalTable: "FrameworkGroups",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysDailySubstitutionRequestBill_SysOrg_OrgId",
                        column: x => x.OrgId,
                        principalTable: "SysOrg",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysDailySubstitutionRequestBill_SysPerson_PersonId",
                        column: x => x.PersonId,
                        principalTable: "SysPerson",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_SysDailySubstitutionRequestBill_SysPerson_SubstitutePersonId",
                        column: x => x.SubstitutePersonId,
                        principalTable: "SysPerson",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_SysDailyCompOffRequestBill_GroupId",
                table: "SysDailyCompOffRequestBill",
                column: "GroupId");

            migrationBuilder.CreateIndex(
                name: "IX_SysDailyCompOffRequestBill_OrgId",
                table: "SysDailyCompOffRequestBill",
                column: "OrgId");

            migrationBuilder.CreateIndex(
                name: "IX_SysDailyCompOffRequestBill_PersonId",
                table: "SysDailyCompOffRequestBill",
                column: "PersonId");

            migrationBuilder.CreateIndex(
                name: "IX_SysDailyShiftSwapRequestBill_GroupId",
                table: "SysDailyShiftSwapRequestBill",
                column: "GroupId");

            migrationBuilder.CreateIndex(
                name: "IX_SysDailyShiftSwapRequestBill_OrgId",
                table: "SysDailyShiftSwapRequestBill",
                column: "OrgId");

            migrationBuilder.CreateIndex(
                name: "IX_SysDailyShiftSwapRequestBill_PersonId",
                table: "SysDailyShiftSwapRequestBill",
                column: "PersonId");

            migrationBuilder.CreateIndex(
                name: "IX_SysDailyShiftSwapRequestBill_SwapPersonId",
                table: "SysDailyShiftSwapRequestBill",
                column: "SwapPersonId");

            migrationBuilder.CreateIndex(
                name: "IX_SysDailySubstitutionRequestBill_GroupId",
                table: "SysDailySubstitutionRequestBill",
                column: "GroupId");

            migrationBuilder.CreateIndex(
                name: "IX_SysDailySubstitutionRequestBill_OrgId",
                table: "SysDailySubstitutionRequestBill",
                column: "OrgId");

            migrationBuilder.CreateIndex(
                name: "IX_SysDailySubstitutionRequestBill_PersonId",
                table: "SysDailySubstitutionRequestBill",
                column: "PersonId");

            migrationBuilder.CreateIndex(
                name: "IX_SysDailySubstitutionRequestBill_SubstitutePersonId",
                table: "SysDailySubstitutionRequestBill",
                column: "SubstitutePersonId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SysDailyCompOffRequestBill");

            migrationBuilder.DropTable(
                name: "SysDailyShiftSwapRequestBill");

            migrationBuilder.DropTable(
                name: "SysDailySubstitutionRequestBill");
        }
    }
}
